export default {
    set(key, value) {
        if (value === undefined || value === null) {
            return
        }
        if (typeof value === 'object') {
            localStorage.setItem(key, JSON.stringify(value))
        } else {
            localStorage.setItem(key, value)
        }
    },

    get(key) {
        return localStorage.getItem(key)
    },

    getJSON(key) {
        try {
            return JSON.parse(localStorage.getItem(key))
        } catch (e) {
            return null
        }
    },

    remove(key) {
        localStorage.removeItem(key)
    }
}